/*
 * Log_Monitor.h
 *
 *  Created on: Aug 26, 2010
 */

#ifndef LOG_MONITOR_H_
#define LOG_MONITOR_H_


#include <logcli.h>
#include <logview.h>

#include "NamedDataBase.h"
#include "FileLogger.h"

class MLogMonitor
{
    public:
        void LogEventL(const CLogEvent& event, CMyDBClass* iDb, FileLogger* iFileLogger);
        
};
 
class CLogMonitor : public CActive
{
    enum TMonitorStates
    {
        EUninitalised,
        EInitalised,
        EFindingLastLogEventId,
        EReadingLastLogEventId,
        EWaitingChange,
        EReadingLog,
        EReadingFirstLog,
        EDeletingEvent,
        EReadingLogItems
    };
 
    public:
        static CLogMonitor* NewL(MLogMonitor* aCallBack);
        static CLogMonitor* NewLC(MLogMonitor* aCallBack);
        ~CLogMonitor();
 
    protected:
        CLogMonitor(MLogMonitor* aCallBack);
        void ConstructL(void);
        void StartMonitorL();
        void GetLatest();
        void GetFirstEventL();
        void GetNextEventL();
        void DoCancel();
        void RunL();
        void StartFindingLastEventId();
        void GetLastEventId();
 
    private:
        CLogClient*     iLogClient;
        CLogViewRecent* iRecentLogView;
        TMonitorStates  iState;
        MLogMonitor*    iCallBack;
        RFs             iFsSession;
        CMyDBClass* 	iDb;
        FileLogger*		iFileLogger;
        TLogId 			lastLogEventId;
};

#endif /* LOG_MONITOR_H_ */
